# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Brett Cornwall <ainola@archlinux.org>
# Contributor: Jakub Luzny <limoto94@gmail.com>
# Contributor: SanskritFritz (gmail)

pkgname=sl
pkgver=5.05
pkgrel=4
pkgdesc='Steam Locomotive runs across your terminal when you type "sl" as you meant to type "ls"'
arch=('loong64' 'x86_64')
# The original project: https://github.com/mtoyoda/sl
# We use a slightly-less dead fork that contains useful patches, such as SIGINT support
url="https://github.com/eyJhb/sl"
license=('custom')
depends=('ncurses')
source=(
	"$pkgname-$pkgver.tar.gz::https://github.com/eyJhb/sl/archive/$pkgver.tar.gz"
	"system_ldflags.patch"
)
sha512sums=('4a57737a60c90a1eec2210ce7c28db937b46a5c35006bd1b5ff43d20ef617a004c49c2b2897ebc0fb8c57b6687fe933b2c9834f5800fdc0bf9912e07542a3b30'
            'cf4592f1f1b2dfe431e8f993a9395900a6a05e6704ce2be32fddab74de8bede2a82c006b82496e50de3ba3c76bda978947f77f251ec41d9391b4db0479bf60c8')

prepare() {
	cd "sl-$pkgver"
	patch < ../system_ldflags.patch
}

build() {
	cd "sl-$pkgver"

	make
	gzip -9 -f sl.1
}

package() {
	cd "sl-$pkgver"

	install -Dm 775 sl "$pkgdir/usr/bin/sl"
	install -Dm 644 sl.1.gz "$pkgdir/usr/share/man/man1/sl.1.gz"
	install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
